<!doctype html>
<html class="no-js">
<head>
<% include("/common/admin_head.html",{title: '添加/编辑品牌', validatorJS: true, loadUE: true}){}%>
<%var isAdd = false;
  var isEdit = false;
  if(isEmpty(brand.id)){
	isAdd = true;
  }else{	
    isEdit = true;
  }%>
</head>
<body>
<!-- content start -->
<div class="admin-content">
  <div class="admin-content-body">
    <div class="am-cf app-padding-title">
      <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">商品管理</strong> / <small><%if(isAdd){%>添加品牌<%}else{%>编辑品牌<%}%></small>
      </div>
    </div>
  
    <hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-0" />
    
    <form class="validator-form" action="<%if(isAdd){%>${base}/brand/save<%}else{%>${base}/brand/update<%}%>" enctype="multipart/form-data" method="post">
    <input type="hidden" name="brand.id" value="${brand.id!}" />
    <div class="am-form am-margin am-form-horizontal">
      <div class="am-form-group am-form-group-sm">
        <label class="am-u-sm-4 am-u-md-3 am-text-right am-form-label">品牌名称</label>
        <div class="am-u-sm-8 am-u-md-9">
          <input type="text" class="am-form-field" name="brand.name" value="${brand.name!}" required />
          <div class="am-text-warning am-margin-top-xs am-text-xs">${nameMessages!}</div>
        </div>
      </div>
      <div class="am-form-group am-form-group-sm">
        <label class="am-u-sm-4 am-u-md-3 am-text-right am-form-label">LOGO</label>
        <div class="am-u-sm-4 am-u-md-6 am-form-file">
          <button type="button" class="am-btn am-btn-default am-btn-sm">
          <i class="am-icon-cloud-upload"></i> 上传图片</button>
          <input id="doc-form-file" type="file" name="logo">
        </div>
        <div class="am-u-sm-4 am-u-md-3">
          <div id="file-list">
            <%if (isEdit && brand.logo != null){%><a href="${base}${brand.logo}" class="am-btn am-btn-default am-btn-sm" target="_blank">查看</a><%}%>
          </div>
        </div>
      </div>
      <div class="am-form-group am-form-group-sm">
        <label class="am-u-sm-4 am-u-md-3 am-text-right am-form-label">网址</label>
        <div class="am-u-sm-8 am-u-md-9">
          <input type="url" class="am-form-field" name="brand.url" value="${brand.url!}" placeholder="必须以http://开头" required />
          <div class="am-text-warning am-margin-top-xs am-text-xs">${urlMessages!}</div>
        </div>
      </div>
      <div class="am-form-group am-form-group-sm">
        <label class="am-u-sm-4 am-u-md-3 am-text-right am-form-label">排序</label>
        <div class="am-u-sm-8 am-u-md-9">
          <input type="number" class="am-form-field" name="brand.orderList" value="${brand.orderList!50}" placeholder="只允许输入零或正整数" min="0" max="1000" required />
          <div class="am-text-warning am-margin-top-xs am-text-xs">${orderListMessages!}</div>
        </div>
      </div>
      <div class="am-form-group am-form-group-sm">
        <label class="am-u-sm-4 am-u-md-3 am-text-right am-form-label">介绍描述</label>
        <div class="am-u-sm-8 am-u-md-9">
          <script id="editor" name="brand.introduction" type="text/plain">${brand.introduction!}</script>
        </div>
      </div>
      <hr data-am-widget="divider" class="am-divider am-divider-dashed" />
      <div class="am-form-group am-form-group-sm">
        <div class="am-u-sm-8 am-u-sm-offset-4 am-u-md-9 am-u-md-offset-3">
          <button type="submit" class="am-btn am-btn-primary"><span class="am-icon-save">  保  存</span></button>
          <button type="button" class="am-btn am-btn-default" onclick="window.history.back(); return false;"><span class="am-icon-undo">  返  回</span></button>
        </div>
      </div>
    </div>
    </form>
  </div>
</div>
<!-- content end -->
<script>
  $(function() {
    $('#doc-form-file').on('change', function() {
      var fileNames = '';
      $.each(this.files, function() {
        fileNames += '<span class="am-badge">' + this.name + '</span> ';
      });
      $('#file-list').html(fileNames);
    });
  });
</script>
</body>
</html>
